import java.util.Stack;

public class Solution {
    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushA.length; i++) {
            stack.push(pushA[i]);
            while (!stack.empty()
                    &&stack.peek()==popA[j]
                    &&j< popA.length) {
                stack.pop();
                j++;
            }
        }
        if (stack.empty()) {
            return false;
        }
        return true;
    }
}